package com.qingke.hibernate.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.query.Query;

import com.qingke.hibernate.bean.CourseModel;

public class CourseModelDAO extends SystemDAO{

	public CourseModelDAO(Session session) {
		super(session);
	}
	public List<CourseModel> list(){
		Query<CourseModel> query=session.createQuery("from CourseModel", CourseModel.class);
		return query.getResultList();
	}
	public CourseModel getCourseModelById(int id){
		Query<CourseModel> query=session.createQuery("from CourseModel where id=:id", CourseModel.class);
		query.setParameter("id", id);
		return query.getSingleResult();
	}
	public List<CourseModel> getCourseModelsByCourseTypeId(int courseTypeId){
		Query<CourseModel> query=session.createQuery("from CourseModel where course_type_id=:courseTypeId", CourseModel.class);
		query.setParameter("courseTypeId", courseTypeId);
		return query.getResultList();
	}
	public List<CourseModel> getCourseModelsByCourseId(int courseId){
		Query<CourseModel> query=session.createQuery("from CourseModel where course_id=:courseId", CourseModel.class);
		query.setParameter("courseId", courseId);
		return query.getResultList();
	}
	public List<CourseModel> getCourseModelsByMajorId(int majorId){
		Query<CourseModel> query=session.createQuery("from CourseModel where major_id=:majorId", CourseModel.class);
		query.setParameter("majorId", majorId);
		return query.getResultList();
	}
	public List<CourseModel> getCourseModelsByCourseSetId(int courseSetId){
		Query<CourseModel> query=session.createQuery("from CourseModel where course_set_id=:courseSetId", CourseModel.class);
		query.setParameter("courseSetId", courseSetId);
		return query.getResultList();
	}
	public List<CourseModel> getCourseModelsBySchoolYearId(int schoolYearId){
		Query<CourseModel> query=session.createQuery("from CourseModel where school_year_id=:schoolYearId", CourseModel.class);
		query.setParameter("schoolYearId", schoolYearId);
		return query.getResultList();
	}
}
